import request from '@/utils/request'

export function getDeliveryUsableList(query) {
  let baseUrl = "/sale/delivery"
  if(query != undefined){
    if(typeof query == "object"){
      console.log(query)
      if(query.hasOwnProperty('deliveryID')){
        query['deliveryID'] = parseInt(query['deliveryID'])
        if(isNaN(query['deliveryID']) == false){
          baseUrl = baseUrl+"-"+query['deliveryID']
        }
      }
    }
  }
  return request({
    url: baseUrl,
    method: 'get'
  })
}

export function getDeliveryList(query) {
  return request({
    url: '/sale/admin/delivery/getList',
    method: 'post',
    data: query
  })
}
export function saveDelivery(query) {
  return request({
    url: '/sale/admin/delivery/save',
    method: 'post',
    data: query
  })
}

export function removeDelivery(query) {
  return request({
    url: '/sale/admin/delivery/remove',
    method: 'post',
    data: query
  })
}
export function getDeliveryDetail(query) {
  if(query != undefined){
    query = JSON.parse(JSON.stringify(query))
  }
  return request({
    url: '/sale/admin/delivery/info/0',
    method: 'get',
    data: query
  })
}